package com.zzxz.practicaltrainingsys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zzxz.practicaltrainingsys.entity.College;
import com.zzxz.practicaltrainingsys.entity.School;
import com.zzxz.practicaltrainingsys.entity.Topic;
import com.zzxz.practicaltrainingsys.mapper.TopicMapper;
import com.zzxz.practicaltrainingsys.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TopicServiceImpl implements TopicService {

    @Autowired
    private TopicMapper TopicMapper;

    @Override
    public List<Topic> getTopic() {
        return TopicMapper.getTopic();
    }

    @Override
    public List<String> getTopicTypes() {
        return TopicMapper.getTopicTypes();
    }

    @Autowired
    private TopicMapper topicMapper;
    @Override
    public List<Topic> getTopicsByProjectId(Integer project_id) {
        return topicMapper.getTopicsByProjectId(project_id);
    }

    @Override
    public int insertTopic(Topic topic) {
        return TopicMapper.insertTopic(topic);
    }

    //更新选题信息
    @Override
    public int updateTopic(Topic topic) {
            return  TopicMapper.updateTopic(topic);
    }

    @Override
    public int deleteTopicById(Integer topic_id) {
        return TopicMapper.deleteTopicById(topic_id);
    }

    @Override
    public PageInfo<Topic> findTopicPages(Integer pageNum, Integer pageSize) {
        PageHelper.startPage( pageNum,pageSize);
        List<Topic> lists = TopicMapper.getTopic();
        return new PageInfo<>(lists);
    }

    @Override
    public List<Topic> getTopicByTopicType(String topic_type) {
        return TopicMapper.getTopicByTopicType(topic_type);
    }

    @Override
    public String getTopicState(Integer topic_id) {
        return TopicMapper.getTopicState(topic_id);
    }


    //在新增项目时更新选题状态
    @Override
    public int updateTopicStateWhenInsertProject(Integer topic_id, String topic_state) {
        return TopicMapper.updateTopicStateWhenInsertProject(topic_id,topic_state);
    }

    @Override
    public School getSchoolById(Integer school_id) {
        return topicMapper.getSchoolById(school_id);
    }

    @Override
    public College getCollegeById(Integer college_id) {
        return topicMapper.getCollegeById(college_id);
    }


}
